package main


import (
	"fmt"
	"bufio"
	"strings"
	"os"
	"strconv"
)
func solve(words []string,dlen int)(ans []string){
	i,n:=0,len(words)
	for{
		start:=i
		wordLen:=0
		for ;i<n&&wordLen+len(words[i])+i-start<=dlen;i++{
			wordLen+=len(words[i])
		}
		if i==n{
			s:=strings.Join(words[start:],"*")
			ans=append(ans,s+strings.Repeat("*",dlen-len(s)))
			return
		}
		fnum:=dlen-wordLen
		if i-start==1{
			ans=append(ans,words[start]+strings.Repeat("*",fnum))
		}else{
			avg,ext:=fnum/(i-start-1),fnum%(i-start-1)
			avgn:=strings.Repeat("*",avg)
			s1:=strings.Join(words[start:start+ext+1],avgn+"*")
			s2:=strings.Join(words[start+ext+1:i],avgn)
			ans=append(ans,s1+avgn+s2)
		}
	}
}

func main(){
	cin:=bufio.NewReader(os.Stdin)
	s,_:=cin.ReadString('\n')
	s=strings.Trim(s,"\n")
	n,_:=cin.ReadString('\n')
	n=strings.Trim(n,"\n")
	v:=strings.Split(s,",")
	// for _,vv:=range v{
	// 	fmt.Printf("%v ",vv)
	// }
	rn,_:=strconv.Atoi(n)
	//fmt.Printf("\n%d\n",rn)
	ans:=solve(v,rn) 
	for _,vv:=range ans{
		fmt.Printf("%v\n",vv)
	}
}